home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 April / macformat-023.iso / Shareware City / Applications / chipmunkbasic3.10 / ucase.bas < prev    next >
Encoding:
BASIC Source File  |  1994-12-20  |  957 b   |  31 lines  |  [TEXT/cBaS]

  1. 100 rem subroutine tests
  2. 110 b$ = "HelLo"
  3. 120 print countcaps(b$);" capital letters in ";b$
  4. 130 print ucase$(b$);" is all capital letters"
  5. 140 print "{";spc$(4);"} should be 4 spaces between the brackets"
  6. 150 for i = 1 to 10 : print fib(i); : next i : print " are fibonacci numbers"
  7. 190 end
  8. 8000 sub fib(n,a,b) : rem recursive fibonacci number
  9. 8010 if n < 2 then return(1)
  10. 8020 return(fib(n-1)+fib(n-2))
  11. 9000 sub ucase$(a$,b$,i,c,n) : rem convert a$ to upper case
  12. 9010 b$ = ""
  13. 9020 n = len(a$)
  14. 9030 for i = 1 to n
  15. 9040   c = asc(mid$(a$,i,1))
  16. 9050   if c > 96 then c = c-32
  17. 9060   b$ = b$+chr$(c)
  18. 9070 next i
  19. 9080 return(b$)
  20. 9100 sub countcaps(a$,i,n,c$) : rem count capital letters in a$
  21. 9110 n = 0
  22. 9120 for i = 1 to len(a$)
  23. 9130   c$ = mid$(a$,i,1) : if c$ >= "A" and c$ <= "Z" then n = n+1
  24. 9140 next i
  25. 9150 return(n)
  26. 9200 sub spc$(n,b$,i) : rem create a string of n spaces
  27. 9210 b$ = ""
  28. 9220 for i = 1 to n : b$ = b$+" " : next i
  29. 9230 return(b$)
  30. 9990 end
  31.